// import './assets/main.css'

import { createApp, render } from 'vue'
import App from './App.vue'
import router from './router'
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper'

// 使用乾坤渲染
renderWithQiankun({
    // 挂载时
    mount(props) {
        console.log('mount');
        render(props)
    },
    // 更新时
    bootstrap() {
        console.log('bootstrap');

    },
    // 卸载时
    unmount(props) {
        console.log('unmount', props);

    }
})
// 非乾坤环境直接渲染
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
    render()
}

function render(props = {}) {
    const { container } = props  // 获取父应用传递过来的容器
    const app = createApp(App)  // 创建vue实例
    app.use(router)  // 挂载路由
    app.mount(container ? container.querySelector('#app') : '#app')  // 挂载到容器中
}
